<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class Group extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'logo' => empty($this->logo) ? '' : asset_url($this->logo),
            'links' => [
                'self' => route('group', ['id' => $this->id])
            ],
            'count' => $this->count,
            'is_official' => (bool)$this->is_official,
            'join_type' => $this->join_type,
        ];
    }
}
